<?php
require_once('conn.php');
require_once('functions.php');
$uid = $_GET['id'];
$user = $mysql->query("select * from `user` where `id` = $uid");
$username = $user[0]['name'];
$img = $user[0]['head'];
$row_user = $mysql->query($sql);
//徒弟数
$studentNum = $mysql->query("select count(*) as num from `user` WHERE `pid`={$uid} AND `login` = 1");
$studentNumNoOpenid = $mysql->query("select count(*) as num from `user` WHERE `pid`={$uid}  AND `login` = 1 AND openid is null");
//有阅读过文章的徒弟数
$studentBenefit = $mysql->query("select COUNT(DISTINCT sid) as num  from `score_detail` WHERE `uid`={$uid} AND `content` like '%徒弟文章阅读%'");
//徒弟注册不同ip个数
$studentIpNum = $mysql->query("select COUNT(DISTINCT ip) as num from user where `pid` = {$uid}  AND `login` = 1");
//徒弟安卓注册个数
$studentAndroidNum = $mysql->query("select count(device) as num  from user where `pid` = {$uid} AND `device` = 'android' AND `login` = 1 ");
//徒弟苹果注册个数
$studentIphoneNum = $mysql->query("select count(device) as num  from user where `pid` = {$uid} AND `device` = 'iphone' AND `login` = 1");
//徒弟pc注册个数
$studentPcNum = $mysql->query("select count(device) as num  from user where `pid` = {$uid} AND `device` = 'pc' AND `login` = 1");
//徒弟绑定微信数目
$haveOpenid = $studentNum[0]['num'] - $studentNumNoOpenid[0]['num'];
//徒弟中收徒过的徒弟数
$studentSql = "select count(DISTINCT pid) as num from user where pid in (select id from `user` where pid={$uid})";
$sstudentNumResult = $mysql->query($studentSql);
$sstudentNum = $sstudentNumResult[0]['num'];
//总提现金额
$txmoney = $mysql->query("select sum(money) as money from `txdata` WHERE `uid`={$uid} AND `state`=2");
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>微有趣</title>
		<meta name="keywords" content=""/>
		<meta name="description" content=""/>
		<meta name="apple-mobile-web-app-capable" content="yes"/>
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no">
		<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
		<link rel="stylesheet" type="text/css" href="./assets/css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="assets/css/user_detail.css"/>
		<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	</head>
	<body>
		<div class="wrap">
			<header>
				<div class="user_id">用户ID:<?=$uid?></div>
				<div class="user_head">
					<div class="head_style">
						<img src="<?=$img?>" alt="" />
					</div>
					<p class="user_name"><?=$username?></p>
				</div>
				<div class="user_score">
					<span class="jf">总积分：<?=$user[0]['total']?></span><span class="jb">总金币：<?=$user[0]['gold']?></span>
				</div>
			</header>
			<div class="main">
				<ul class="con_detail">
					<li class="clearfix"><span>徒弟总数(有登录)：</span><span><?=$studentNum[0]['num']?></span></li>
					<li class="clearfix"><span>徒弟绑定微信个数：</span><span><?=$haveOpenid?></span></li>
					<li class="clearfix"><span>徒弟有贡献个数(有阅读文章)：</span><span><?=$studentBenefit[0]['num']?></span></li>
					<li class="clearfix"><span>有收徒的徒弟个数：</span><span><?=$sstudentNum?></span></li>
					<li class="clearfix"><span>徒弟注册不同ip个数：</span><span><?=$studentIpNum[0]['num']?></span></li>
					<li class="clearfix"><span>徒弟安卓注册个数：</span><span><?=$studentAndroidNum[0]['num']?></span></li>
					<li class="clearfix"><span>徒弟苹果注册个数：</span><span><?=$studentIphoneNum[0]['num']?></span></li>
					<li class="clearfix"><span>徒弟pc注册个数：</span><span><?=$studentPcNum[0]['num']?></span></li>
					<li class="clearfix"><span>总提现金额：</span><span><?=$txmoney[0]['money']?></span></li>
				</ul>
				<ul class="list">
					<li id="income" onclick="jump(1)">
						<div class="icon_2">
							<img src="assets/images/user_detail/income.png"/>
						</div>
						<p class="income">积分明细</p>
					</li>
					<li id="student" onclick="jump(2)">
						<div class="icon_1">
							<img src="assets/images/user_detail/student.png"/>
						</div>
						<p class="student">徒弟详情</p>
					</li>
					
					<li id="exchange" onclick="jump(3)">
						<div class="icon_3">
							<img src="assets/images/user_detail/exchange.png"/>
						</div>
						<p class="exchange">提现详情</p>
					</li>
				</ul>
			</div>
		</div>
	</body>
	<script type="text/javascript">
		function jump(sum){
			switch(sum){
				case 1:window.location.href = "user_detail_con.php?id=<?=$uid?>&do=income";break;
				case 2:window.location.href = "user_detail_con.php?id=<?=$uid?>&do=students";;break;
				case 3:window.location.href = "user_detail_con.php?id=<?=$uid?>&do=record";break;
				default:break;
			}
		}
	</script>
</html>
